//index.js
//获取应用实例
const app = getApp()
var QQMapWX = require('../../utils/qqmap-wx-jssdk');
var qqmapsdk = new QQMapWX({
  key: 'JJMBZ-X2AKG-G5LQG-IXN2I-CRMAF-24B5R'
});
Page({
  data: {
    longitude: '',
    latitude: '',
    dzName:""
  },
  onLoad: function () {},
  btn() {
    wx.getLocation({
      type: 'wgs84',
      altitude: true,
      success: (res) => {
        this.setData({
          longitude: res.longitude,
          latitude: res.latitude
        })
        qqmapsdk.reverseGeocoder({
          location: {
            latitude: res.latitude,
            longitude: res.longitude
          },
          success: (res) => {
            wx.showModal({
              title: '位置',
              content: res.result.address,
            })

            let dzObj=res.result.address_component
            this.setData(
              {
                dzName:dzObj.province+''+dzObj.city+''
              }
            )
          }
        })
      }
    })
    // wx.chooseLocation({
    //   success: (res) => {
    //     console.log(res)
    //   }
    // })
  }
})